ROOT_DIR = $(PWD)
LIB_DIR = $(ROOT_DIR)/lib
OBJ_DIR = $(ROOT_DIR)/obj
SRC_DIR = $(ROOT_DIR)/src
TARGET = $(ROOT_DIR)/bin/RtspClient
TARGET_CROSS = $(ROOT_DIR)/bin/cross/RtspClient
OBJS = $(subst /src,/obj,$(subst .cpp,.o,$(shell find $(SRC_DIR) -name "*.cpp")))

CXX := g++
LDFLAGS = -lssl -lcrypto -lpthread
CXXFLAGS = -Wall -O2 -std=c++11 
AFTER_COMPILE := sudo ./bin/RtspClient

LINK_CAMMADN := make -C obj

ifeq ($(C), T)
	CXX := aarch64-linux-gnu-g++
	LDFLAGS = -L$(LIB_DIR)/openssl -lssl -lcrypto -lpthread
	CXXFLAGS = -Wall -O2 -std=c++11 -I$(LIB_DIR)/openssl/include
	AFTER_COMPILE = scp $(TARGET_CROSS) linaro@192.168.21.78:/home/linaro/AiServer

	OBJ_DIR = $(ROOT_DIR)/obj/obj_cross
	OBJS = $(subst /src,/obj/obj_cross,$(subst .cpp,.o,$(shell find $(SRC_DIR) -name "*.cpp")))
	LINK_CAMMADN := make -C obj/obj_cross
endif

export CXX CXXFLAGS LDFLAGS OBJ_DIR OBJS TARGET TARGET_CROSS

all : src obj
	clear
	make -C src
	$(LINK_CAMMADN)
	@echo "---------------项目构建完成---------------"
	$(AFTER_COMPILE)

clean:
	rm -rf ./obj/*.o ./obj/obj_cross/*.o $(TARGET) $(TARGET_CROSS)
	@echo "---------------项目清理完成---------------"